# eric7.Plugins.UiExtensionPlugins.Translator.TranslatorEngines.TranslationEngine

Module implementing the translation engine base class.

### Global Attributes

None

### Classes

TranslationEngine | Class implementing the translation engine base class containing default methods.

### Functions

None

## TranslationEngine

Class implementing the translation engine base class containing default methods.

### Signals

availableTranslationsLoaded()
  emitted to indicate the availability of the list of supported translation languages

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

TranslationEngine | Constructor
engineName | Public method to get the name of the engine.
getTextToSpeechData | Public method to pronounce the given text.
getTranslation | Public method to translate the given text.
hasTTS | Public method indicating the Text-to-Speech capability.
supportedLanguages | Public method to get the supported languages.
supportedTargetLanguages | Public method to get a list of supported target languages for an original language.

### Static Methods

None

#### TranslationEngine (Constructor)

TranslationEngine(plugin, parent=None)

Constructor

plugin (TranslatorPlugin)
  reference to the plugin object
parent (QObject)
  reference to the parent object

#### TranslationEngine.engineName

engineName()

Public method to get the name of the engine.

Return:
  engine name

Return Type:
  str

#### TranslationEngine.getTextToSpeechData

getTextToSpeechData(requestObject, text, language)

Public method to pronounce the given text.

requestObject (TranslatorRequest)
  reference to the request object (unused)
text (str)
  text to be pronounced (unused)
language (str)
  language code of the text (unused)

Return:
  tuple with pronounce data or an error string and a success flag

Return Type:
  tuple of (QByteArray or str, bool)

#### TranslationEngine.getTranslation

getTranslation(requestObject, text, originalLanguage, translationLanguage)

Public method to translate the given text.

requestObject (TranslatorRequest)
  reference to the request object (unused)
text (str)
  text to be translated (unused)
originalLanguage (str)
  language code of the original (unused)
translationLanguage (str)
  language code of the translation (unused)

Return:
  tuple of translated text and flag indicating success (unused)

Return Type:
  tuple of (str, bool)

#### TranslationEngine.hasTTS

hasTTS()

Public method indicating the Text-to-Speech capability.

Return:
  flag indicating the Text-to-Speech capability

Return Type:
  bool

#### TranslationEngine.supportedLanguages

supportedLanguages()

Public method to get the supported languages.

Return:
  list of supported language codes

Return Type:
  list of str

#### TranslationEngine.supportedTargetLanguages

supportedTargetLanguages(original)

Public method to get a list of supported target languages for an original language.

Note: The default implementation return the list of supported languages (i.e. the same as those for the source) with the given original removed.

original (str)
  original language

Return:
  list of supported target languages for the given original

Return Type:
  list of str

Up